﻿using Aop.Api;
using Aop.Api.Domain;
using Aop.Api.Request;
using Aop.Api.Response;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JinfuyuanProject.AliPayDemo;
public partial class wappay_refund : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void BtnAlipay_Click(object sender, EventArgs e)
    {
        DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

        // 商户订单号，和交易号不能同时为空
        string out_trade_no ="123";

        // 支付宝交易号，和商户订单号不能同时为空
        string trade_no = "123";

        // 退款金额，不能大于订单总金额
        string refund_amount = "123";

        // 退款原因
        string refund_reason = "123";

        // 退款单号，同一笔多次退款需要保证唯一，部分退款该参数必填。
        string out_request_no = "123";

        AlipayTradeRefundModel model = new AlipayTradeRefundModel();
        model.OutTradeNo = out_trade_no;
        model.TradeNo = trade_no;
        model.RefundAmount = refund_amount;
        model.RefundReason = refund_reason;
        model.OutRequestNo = out_request_no;

        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
        request.SetBizModel(model);

        AlipayTradeRefundResponse response = null;
        try
        {
            response = client.Execute(request);
            //WIDresule.Text = response.Body;

        }
        catch (Exception exp)
        {
            throw exp;
        }
    }
}